package com.zl.autocode.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zl.autocode.controller.base.AutocodeBaseController;
import com.zl.autocode.dto.autocode.ddlTemplate.ReqDdlTemplateAddDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ReqDdlTemplateDelDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ReqDdlTemplateDetailDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ReqDdlTemplateEditDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ReqDdlTemplateQueryDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ReqDdlTemplateStateDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ResDdlTemplateAddDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ResDdlTemplateDelDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ResDdlTemplateDetailDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ResDdlTemplateEditDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ResDdlTemplateQueryDTO;
import com.zl.autocode.dto.autocode.ddlTemplate.ResDdlTemplateStateDTO;
import com.zl.autocode.service.autocode.IDdlTemplateService;
import com.zl.common.dto.ReqDTO;
import com.zl.common.dto.ResDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 建表sql模板
 * @author ZL
 */
@Api(value="建表sql模板",tags ="建表sql模板")
@RestController("autocodeDdlTemplateController")
@RequestMapping("/autocode/ddlTemplate")
public class DdlTemplateController extends AutocodeBaseController {

    @Autowired
    private IDdlTemplateService ddlTemplateService;
    
    /**
     * 查询
     */
    @ApiOperation(value="建表sql模板-查询")
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public ResDTO<ResDdlTemplateQueryDTO> listTemplate(@RequestBody ReqDTO<ReqDdlTemplateQueryDTO> reqInfo) throws Exception{
        ResDdlTemplateQueryDTO data = ddlTemplateService.queryDdlTemplateList(reqInfo);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="建表sql模板-详情")
    @RequestMapping(value="/detail", method = RequestMethod.POST)
    public ResDTO<ResDdlTemplateDetailDTO> detailTemplate(@RequestBody ReqDTO<ReqDdlTemplateDetailDTO> reqInfo) throws Exception{
        ResDdlTemplateDetailDTO data = ddlTemplateService.queryDdlTemplateDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="建表sql模板-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
        public ResDTO<ResDdlTemplateAddDTO> addTemplate(@RequestBody ReqDTO<ReqDdlTemplateAddDTO> reqInfo) throws Exception{
        ResDdlTemplateAddDTO data = ddlTemplateService.insertDdlTemplateInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="建表sql模板-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
        public ResDTO<ResDdlTemplateEditDTO> editTemplate(@RequestBody ReqDTO<ReqDdlTemplateEditDTO> reqInfo) throws Exception{
        ResDdlTemplateEditDTO data = ddlTemplateService.updateDdlTemplateInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="建表sql模板-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
        public ResDTO<ResDdlTemplateDelDTO> delTemplate(@RequestBody ReqDTO<ReqDdlTemplateDelDTO> reqInfo) throws Exception{
        ResDdlTemplateDelDTO data = ddlTemplateService.deleteDdlTemplateInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="建表sql模板-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
        public ResDTO<ResDdlTemplateStateDTO> stateTemplate(@RequestBody ReqDTO<ReqDdlTemplateStateDTO> reqInfo) throws Exception{
        ResDdlTemplateStateDTO data = ddlTemplateService.updateDdlTemplateState(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="建表sql模板-删除")
    @RequestMapping(value="/delTemplateAndDetail", method = RequestMethod.POST)
        public ResDTO<ResDdlTemplateDelDTO> delTemplateAndDetail(@RequestBody ReqDTO<ReqDdlTemplateDelDTO> reqInfo) throws Exception{
        ResDdlTemplateDelDTO data = ddlTemplateService.deleteDdlTemplateAndDetail(reqInfo);
        return successDATA(data); 
    }
}